package com.hang.controller;

import com.hang.common.Result;
import com.hang.service.ClazzService;
import com.hang.service.ClazzStudentService;
import com.hang.service.TeacherService;
import com.hang.vo.ClazzVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Api(tags = "教师管理接口")
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "teacher/admin")
public class TeacherManageController {
    private final TeacherService teacherService;

    private final ClazzStudentService clazzStudentService;

    private final ClazzService clazzService;

    @ApiOperation(value = "导入班级——学生信息")
    @PostMapping("/importData/{clazzId}")
    public Result importStudentClazzData(
            @PathVariable("clazzId") String clazzId,
            @RequestParam("file")MultipartFile multipartFile
            ){
        clazzStudentService.importData(clazzId,multipartFile);

        //更新班级人数
        clazzStudentService.updateClazzCount(clazzId);
        return Result.ok();
    }

    @ApiOperation(value = "新建班级")
    @PostMapping("/createClass")
    public Result createClazz(@ApiParam("班级实体类") ClazzVo clazzVo){
        clazzService.createClazz(clazzVo);
        return Result.ok();
    }

}